package com.chenye.reflect;

import java.util.Collections;
import java.util.Random;

/**
 * @Auther:chenye
 * @Data:2018/7/19
 * @Description:
 */
public class Person extends Human{
    private String name = "person name";
    private Integer age;
    public static final int num1 = 1;//编译时常量
    public static int num2 = 2; //会触发类初始化，也会调用 static{} 代码块
    public final String str = "str";
    public static final int b = "hello".length(); //运行时常量 会触发类的初始化
    public static final int a = new Random().nextInt();
    //静态块，父类初始化时会调用
    static{
        System.out.println("类初始化！");
    }

    public Person() {
        System.err.println("init");
    }

    @Override
    void hh() {
        this.name = "parent set name";
        System.err.println("person hh");
    }

    public Person(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }


    public static final void say(){
        System.err.println("static final say");
    }

    public static void main(String[] args){

//        System.out.println(Test.a);
//        System.out.println(Test.s);
//      System.out.println(Test.b);
//      System.out.println(Test.a2);
      System.out.println(Test.a3);
//      System.out.println(Test.e);
//        System.err.println(E.A);
    }
}
class Test{
    static{
        System.out.println("Test正在被初始化");
    }
    public static final int a = 10;
    public static final int b = "test".length();
    public static final String s = "world";
    public static Integer a2 = 20;
    public static final A a3 = new A();
    public static final E e = E.A;

    public static void main(String[] args){
//        Person person = new Person();
        System.err.println(Person.num2);
//        System.err.println(Person.b);
//        Person.say();
    }
}
class A{
    static{
        System.err.println("A init");
    }
}
enum E{
    A,B,C,D,E,F,G;
    static{
        System.err.println("enum init");
    }
}